package com.tocean.app.controller.common;

import com.tocean.app.controller.request.paper.PaperOperateDto;
import com.tocean.app.controller.request.paper.PaperSearchDto;
import com.tocean.app.controller.request.paper.PaperTopicDto;
import com.tocean.app.controller.request.topic.TopicDto;
import com.tocean.app.controller.request.wrongset.WrongSetDto;
import com.tocean.app.dto.request.BasePageRequest;
import com.tocean.app.dto.response.BasePageResponse;
import com.tocean.app.dto.response.BaseResponse;
import com.tocean.app.entity.common.PaperTopic;
import com.tocean.app.entity.common.TestPaper;
import com.tocean.app.entity.common.WrongSet;
import com.tocean.app.mapper.common.PaperTopicMapper;
import com.tocean.app.service.common.PaperService;
import com.tocean.app.service.common.TopicService;
import com.tocean.app.service.common.WrongSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "错题集管理")
@Slf4j
@RestController
@RequestMapping("/common/wrong")
public class WrongSetController {

    @Autowired
    private WrongSetService wrongSetService;

    @ApiOperation(value = "根据用户id,题目id新增错题")
    @PostMapping("/add/{uid}/{tid}")
    public BaseResponse<WrongSetDto> addWrongTopic( @PathVariable("uid") String uid,@PathVariable("tid") String tid ) {
        wrongSetService.AddStem(uid,tid);
        return BaseResponse.success();
    }

    @ApiOperation(value = "根据用户id,题目id删除错题")
    @DeleteMapping("/rf/{uid}/{tid}")
    public BaseResponse<?> delete(@PathVariable("uid") String uid,@PathVariable("tid") String tid ) {
        wrongSetService.delete(uid,tid);
        return BaseResponse.success();
    }

    @ApiOperation(value = "根据用户id获取错题")
    @GetMapping("/get/{uid}")
    public BaseResponse<?> query(@PathVariable("uid") String uid) {

        return BaseResponse.success(wrongSetService.query(uid));
    }


}
